import Vue from "vue"
import VueRouter from "vue-router"
import routerLayout from "./layout/router-layout.vue"
Vue.use(VueRouter)
const pages = import.meta.glob("./pages/**/*.{vue,tsx,jsx}")
const routes = Object.entries(pages).map(([filename, component]) => {
  const componentName = filename
    .split("/")
    .pop()
    ?.replace(/\.(vue|tsx|jsx)$/, "")
  return {
    path: `/${componentName}`,
    name: componentName,
    component,  
    meta: { page: true },
  }
})
const createRouter = () =>
  new VueRouter({
    routes: [
      {
        path: "/",
        component: routerLayout,
        children: routes,
      },
    ],
  })

const router = createRouter()
export default router
